#!/usr/bin/env python
import os, sys, inspect, utils
from os import path

Import('build')

Env = build.env.Clone()
Env.Append(CPPDEFINES=('KROLL_PYTHON_API_EXPORT', 1))
build.add_thirdparty(Env, 'poco')

if build.is_osx():
	Env.Append(CPPPATH=['/System/Library/Frameworks/Python.framework/Versions/Current/Headers',build.kroll_include_dir])
	Env.Append(FRAMEWORKS=['Python'])

elif build.is_linux():
	Env.Append(CPPPATH=[
		'/usr/lib/python/2.5/i386-linux',
		'/usr/include/python2.5',
		build.kroll_include_dir])
	Env.Append(LIBS=['python2.5'])

elif build.is_win32():
	python_home = os.environ['PYTHONHOME']
	Env.Append(CPPPATH=[os.path.join(python_home, 'include'),build.kroll_include_dir])
	Env.Append(LIBPATH=[os.path.join(python_home, 'libs')])
	Env.Append(LIBS=['python25'])
	Env.Append(CCFLAGS = ['/MD'])

m = build.add_module('python', env=Env)
t = Env.SharedLibrary(m.build_dir + '/pythonmodule', Glob('*.cpp'))
build.mark_build_target(t)

if build.is_win32():
	m.light_weight_copy('#python-win32-resources', build.tp('python'), m.build_dir)
